home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / programming / arexx / amiup20.lha / AmiUp20.rexx < prev   
Encoding:
OS/2 REXX Batch file  |  1995-02-26  |  12.8 KB  |  330 lines

  1. /*************************************************************************/
  2. /*  Name  : AmiUp.rexx                                Version :      2.0 */
  3. /*  Autor : Peter Meyer                               Stand   : 25.02.95 */
  4. /*                                                                       */
  5. /*  $VER: AmiUp.rexx 2.0  © Peter Meyer (25.02.95)                       */
  6. /*                                                                       */
  7. /*  Zweck : Automatic upload of AmiNet files for DLG BBS's. File areas   */
  8. /*          and file comment are taken from the apropriate *.readme.     */
  9. /*                                                                       */
  10. /*  Usage : 'Sys:RexxC/Rx AmiUp.rexx [Batch]'                            */
  11. /*                                                                       */
  12. /*          The BATCH option forces AmiUp not to use any requesters,     */
  13. /*          when the area or the comment couldn't be set correctly,      */
  14. /*          default values are used.                                     */
  15. /*                                                                       */
  16. /*          Successfully uploaded files will be deleted from the source  */
  17. /*          directory.                                                   */
  18. /*                                                                       */
  19. /*  Comm. : The script uses the rexxreqtools.library by Nico Francois    */
  20. /*          the Areas need to be adapted to your BBS configuration.      */
  21. /*                                                                       */
  22. /*            Bug Reports, problems, tips and suggestions to:            */
  23. /*      Peter Meyer FIDO: 2:246/1416.2 or peter@amiuni.tynet.sub.org     */
  24. /*                                                                       */
  25. /*************************************************************************/
  26.  
  27. DefDir  = "Ram:"                 /* Default directory to scan files from */
  28. DefDesc = "No discription found"                  /* Default filecomment */
  29.  
  30. /************************* File Area configuration ***********************/
  31. /*                                                                       */
  32. /* Attention: Fill in the correct number of the apropriate file area for */
  33. /*            your BBS !                                                 */
  34. /*                                                                       */
  35. /*            File area none will be used if AmiUp can't determine the   */
  36. /*            aproriate area in BATCH mode.                              */
  37. /*                                                                       */
  38. /*************************************************************************/
  39.  
  40. none       =   "1"; recent     =   "1"; new        =   "1"
  41.  
  42. biz_dbase  =   "1"; biz_demo   =   "4"; biz_misc   =   "1"; biz_patch  =  "34"
  43.  
  44. comm_bbs   =   "6"; comm_cnet  =   "6"; comm_dlg   = "100"; comm_envoy =  "31"
  45. comm_fido  =   "6"; comm_mail  =   "6"; comm_misc  =   "6"; comm_net   =  "31"
  46. comm_news  =   "6"; comm_term  =   "6"; comm_ums   =   "6"; comm_uucp  =   "6"
  47. comm_bbs_dlg = "100"
  48.  
  49. demo_aga   =   "2"; demo_euro  =   "2"; demo_mag   =   "2"; demo_mega  =   "2"
  50. demo_slide =   "2"; demo_sound =   "2"; demo_tg93  =   "2"
  51.  
  52. dev_amos   =  "10"; dev_asm    =  "10"; dev_basic  =  "10"; dev_c      =  "10"
  53. dev_cross  =  "10"; dev_debug  =  "10"; dev_e      =  "10"; dev_gcc    =  "10"
  54. dev_gui    =  "10"; dev_lang   =  "10"; dev_m2     =  "10"; dev_misc   =  "10"
  55. dev_moni   =  "10"; dev_obero  =  "10"; dev_src    =  "10"
  56.  
  57. disk_bakup =   "3"; disk_cache =   "3"; disk_cdrom =   "3"; disk_misc  =   "3"
  58. disk_moni  =   "3"; disk_optim =   "3"; disk_salv  =   "3";
  59.  
  60. docs_anno  =  "21"; docs_help  =  "21"; docs_hyper =  "21"; docs_mags  =   "7"
  61. docs_misc  =  "21"; docs_rview =  "14"
  62.  
  63. fish_docs  =  "21"
  64.  
  65. game_2play =   "8"; game_demo  =   "4"; game_gag   =   "8"; game_hint  =   "8"
  66. game_jump  =   "8"; game_misc  =   "8"; game_patch =   "8"; game_role  =   "8"
  67. game_shoot =   "8"; game_think =   "8"; games_gag  =   "8"
  68.  
  69. gfx_3d     =  "26"; gfx_3dobj  =   "1"; gfx_aga    =  "26"; gfx_anim   =   "1"
  70. gfx_board  =  "26"; gfx_conv   =  "26"; gfx_edit   =  "26"; gfx_fract  =   "1"
  71. gfx_misc   =  "26"; gfx_pbm    =  "26"; gfx_show   =  "26"; gfx_x11    =   "1"
  72.  
  73. hard_drivr =   "1"; hard_hack  =  "35"; hard_misc  =   "1"
  74.  
  75. info_adt   =   "1"; info_sites =   "1"; info_start =   "1"; info_stats =   "1"
  76.  
  77. misc_amag  =  "25"; misc_antiq =   "1"; misc_edu   =   "1"; misc_emu   =  "30"
  78. misc_math  =   "1"; misc_misc  =   "1"; misc_sci   =   "1"; misc_unix  =   "1"
  79.  
  80. mods_8voic =  "22"; mods_abc   =  "22"; mods_chart =  "22"; mods_def   =  "22"
  81. mods_ghi   =  "22"; mods_jkl   =  "22"; mods_mno   =  "22"; mods_med   =  "22"
  82. mods_misc  =  "22"; mods_pqr   =  "22"; mods_pro   =  "22"; mods_spark =  "22"
  83. mods_st    =  "22"; mods_stu   =  "22"; mods_vwx   =  "22"
  84.  
  85. mus_edit   =   "5"; mus_midi   =   "1"; mus_misc   =   "1"; mus_play   =   "5"
  86. mus_smpl   =  "22"
  87.  
  88. pix_bill   =   "1"; pix_guard  =   "1"; pix_icon   =   "1"; pix_illu   =   "1"
  89. pix_irc    =   "1"; pix_misc   =   "1"; pix_trace  =   "1"; pix_wb     =   "1"
  90.  
  91. text_dtp   =  "27"; text_font  =  "27"; text_hyper =   "1"; text_misc  =   "1"
  92. text_print =   "1"; text_show  =   "3"; text_tex   =  "27"
  93.  
  94. util_app   =  "16"; util_arc   =   "9"; util_batch =   "3"; util_boot  =   "3"
  95. util_blank =   "3"; util_cdity =  "18"; util_cli   =   "3"; util_conv  =   "3"
  96. util_crypt =   "3"; util_dir   =   "3"; util_edit  =   "3"; util_gnu   =   "3"
  97. util_libs  =   "3"; util_misc  =   "3"; util_moni  =   "3"; util_mouse =   "3"
  98. util_pack  =   "9"; util_rexx  =  "17"; util_shell =   "3"; util_virus =  "28"
  99. util_wb    =  "12"
  100.  
  101. /***************************** Main program ******************************/
  102.  
  103. parse arg Batch
  104. if upper(Batch) = "BATCH" then Batch = 1
  105.                           else Batch = 0
  106.  
  107. options results
  108.  
  109. if ~show('L', 'rexxsupport.library') then do
  110.   call addlib('rexxsupport.library', 0, -30, 0)
  111. end
  112. if ~show('L', 'rexxreqtools.library') then do
  113.   call addlib('rexxreqtools.library', 0, -30, 0)
  114. end
  115.  
  116. call GetFileList
  117.  
  118. CommFiles = 0; UpFiles = 0; Dupes = 0
  119. do FileNumber = 1 to Files.count
  120.   FileName = Files.FileNumber; DestName = FileName
  121.   if right(FileName, 7) ~= ".readme" then do
  122.     PointPos = lastpos(".", FileName)
  123.     if PointPos ~= 0 then DestName = substr(FileName, 1, PointPos - 1)
  124.     call CheckSize
  125.     call CommentFile
  126.     call UploadFile
  127.   end
  128. end
  129. say "Selected    : "||Files.count
  130. say "Uloaded     : "||UpFiles
  131. say "Commented   : "||CommFiles
  132. say "Dupes       : "||Dupes
  133.  
  134. if ~Batch then call DeleteList()
  135.  
  136. exit
  137.  
  138. /************************** Get List of Files ****************************/
  139.  
  140. GetFileList:
  141.   if ~Batch then do
  142.     call MakeList()                                  /* create area list */
  143.     call rtfilerequest(DefDir,,"Select files",, "rtfi_flags=freqf_multiselect", Files)
  144.     if Files = "0" then do
  145.       say "Abort: No files selected !"
  146.       call DeleteList()
  147.       exit
  148.     end
  149.     call rtfreefilebuffer()
  150.   end
  151.   if Batch then do
  152.     address command "List QUICK NOHEAD FILES >T:Files.lst"
  153.     call open(FileLst, "T:Files.lst")
  154.     FileNumber = 1
  155.     do while ~eof(FileLst)
  156.       Line = readln(FileLst)
  157.       if Line ~= "" then do
  158.         Files.FileNumber = Line
  159.         FileNumber = FileNumber + 1
  160.       end
  161.     end
  162.     Files.count = FileNumber - 1
  163.   end
  164.   return
  165.  
  166. /**************************** Check File Size ****************************/
  167.  
  168. CheckSize:
  169.   FileInfo = statef(FileName); Free = ""
  170.   if value(subword(FileInfo, 2, 1)) > 409600 then Free = "FREE"
  171.   return
  172.  
  173. /****************************** Comment File *****************************/
  174.  
  175. CommentFile:
  176.   FileDesc = DefDesc; AmiArea = "none"; ReadFound = 0
  177.   ReadName = DestName||".readme"
  178.   if exists(ReadName) then do
  179.     ReadFound = 1
  180.     call open(ReadMe, ReadName)
  181.     do while ~eof(ReadMe)
  182.       Line = readln(ReadMe)
  183.       if left(Line, 6) = "Short:" then do
  184.         FileDesc = compress(strip(substr(Line, 7)), '"''')
  185.         CommFiles = CommFiles + 1
  186.         Line = readln(ReadMe)
  187.       end
  188.       if left(Line, 5) = "Type:" then do
  189.         AmiArea = translate(strip(subword(Line, 2, 1)), "_", "/")
  190.       end
  191.       if FileDesc ~= DefDesc & AmiArea ~= "none" then leave
  192.     end
  193.     call close(ReadMe)
  194.   end
  195.   return
  196.  
  197. /******************************* Upload File *****************************/
  198.  
  199. UploadFile:
  200.   if ~datatype(value(AmiArea), N) then AmiArea = "none"
  201.   if ~Batch & AmiArea = "none" then
  202.     do
  203.       say 'Select area for '||FileName||' : '||FileDesc
  204.       UpArea = PickList(FileName)
  205.       if FileDesc = DefDesc then FileDesc = GetFileDesc(FileName, DefDesc)
  206.       say 'DLGUpload '||FileName||' -a '||UpArea||' -d '||'"'FileDesc'"'||' -u '"'Peter Meyer'"' '||Free
  207.       address command 'DLG:DLGUpload -f '||FileName||' -a '||UpArea||' -d '||'"'FileDesc'"'||' -u '"'Peter Meyer'"' '||Free
  208.       if RC ~= 0 then
  209.         Dupes = Dupes   + 1
  210.       else do
  211.         UpFiles = UpFiles + 1
  212.         call delete(FileName)
  213.         if ReadFound = 1 then call delete(ReadName)
  214.       end
  215.     end
  216.   else
  217.     do
  218.       say 'DLGUpload '||FileName||' -a '||value(AmiArea)||' -d '||'"'FileDesc'"'||' -u '"'Peter Meyer'"' '||Free
  219.       address command 'DLG:DLGUpload -f '||FileName||' -a '||value(AmiArea)||' -d '||'"'FileDesc'"'||' -u '"'Peter Meyer'"' '||Free
  220.       if RC ~= 0 then
  221.         Dupes = Dupes   + 1
  222.       else do
  223.         UpFiles = UpFiles + 1
  224.         call delete(FileName)
  225.         if ReadFound = 1 then call delete(ReadName)
  226.       end
  227.     end
  228.   return
  229.  
  230. /**************************** File description ***************************/
  231.  
  232. GetFileDesc: procedure
  233.   parse arg FileName, DefDesc
  234.   Separator = lastpos("/", FileName)
  235.   if Separator = 0 then Separator = lastpos(":", FileName)
  236.   UFName = substr(FileName, Separator + 1)
  237.   FileDesc = rtgetstring(DefDesc,, "Description of "||UFName,,, Res)
  238.   FileDesc = compress(FileDesc, '"''')
  239.   if Res = 0 then FileDesc = DefDesc
  240.   return FileDesc
  241.  
  242. /****************************** List Requester ***************************/
  243. /*                                                                       */
  244. /* Attention: You have to customize that part of the script !            */
  245. /*                                                                       */
  246. /*************************************************************************/
  247.  
  248. MakeList:
  249.   call NewList()
  250.   call AddList("001   Uploads")
  251.   call AddList("002   Amiga-Demos")
  252.   call AddList("003   Amiga-Utilities")
  253.   call AddList("004   Amiga-Demos (Commerziell)")
  254.   call AddList("005   Amiga-Musik Programme")
  255.   call AddList("006   Amiga-Dfue")
  256.   call AddList("007   Amiga-Magazine")
  257.   call AddList("008   Amiga-Spiele")
  258.   call AddList("009   Amiga-Packer")
  259.   call AddList("010   Amiga-Programmer")
  260.   call AddList("011   Amiga-MUI Anwendungen")
  261.   call AddList("012   Amiga-Workbench")
  262.   call AddList("013   Amiga-Drucker")
  263.   call AddList("014   Amiga-Reviews")
  264.   call AddList("015   Amiga-Gagprogramme")
  265.   call AddList("016   Amiga-Anwendungen")
  266.   call AddList("017   Amiga-ARexx")
  267.   call AddList("018   Amiga-Commodities")
  268.   call AddList("021   Amiga-Texte")
  269.   call AddList("022   Amiga-Modules")
  270.   call AddList("023   Amiga-Benchmarks")
  271.   call AddList("025   Amiga-Disks")
  272.   call AddList("026   Amiga-Grafik")
  273.   call AddList("027   Amiga-TeX Dtp")
  274.   call AddList("028   Amiga-Viren")
  275.   call AddList("029   Amiga-Animationen")
  276.   call AddList("030   Amiga-Emulationen")
  277.   call AddList("031   Amiga-Netzwerke")
  278.   call AddList("033   Amiga-Contents Files")
  279.   call AddList("034   Amiga-Updates Patches")
  280.   call AddList("035   Amiga-Hardware Bauanleiungen")
  281.   call AddList("036   Amiga-Spieletips")
  282.   call AddList("039   Amiga-AmiNet unsortiert")
  283.   call AddList("040   MPEG-Animationen")
  284.   call AddList("090   FIDO-Nodediffs")
  285.   call AddList("091   FIDO-Region 24")
  286.   call AddList("100   DLG-Utilities")
  287.   call AddList("101   DLG-Updates")
  288.   call AddList("102   DLG-Programmers_Support")
  289.   call AddList("103   DLG-DLGMail_Support")
  290.   call AddList("104   DLG-SkyUtilities_Support")
  291.   call AddList("105   DLG-Doors OnlineGames")
  292.   call AddList("110   MISC-Filelisten")
  293.   call AddList("111   MISC-AmiUni Infos")
  294.   call AddList("112   MISC-Bilder (Adult)")
  295.   call AddList("113   MISC-Bilder (IFF GIF TIFF)")
  296.   call AddList("115   MISC-Userbilder")
  297.   call AddList("116   SIRDS")
  298.   call AddList("117   Jupiter")
  299.   call AddList("201   Picasso")
  300.   call AddList("250   HP48")
  301.   call AddList("301   Proxity.beta")
  302.   return
  303.  
  304. NewList: procedure
  305.   address command 'MakeDir T:TempList >NIL:'
  306.   return
  307.  
  308. DeleteList: procedure
  309.   address command 'Delete T:TempList ALL QUIET'
  310.   return
  311.  
  312. AddList: procedure
  313.   parse arg Name
  314.   address command 'Echo "" NOLINE >"T:TempList/'Name'"'
  315.   return
  316.  
  317. PickList: procedure
  318.   parse arg FileName
  319.   Separator = lastpos("/", FileName)
  320.   if Separator = 0 then Separator = lastpos(":", FileName)
  321.   UFName = substr(FileName, Separator + 1)
  322.   UpArea = rtfilerequest("T:TempList","001   Uploads","Select area for "UFName,, "rtfi_flags=0", Res)
  323.   if Res = 0 then
  324.     UpArea = "1"
  325.   else
  326.     UpArea = strip(left(substr(UpArea, 12), 3), L, "0")
  327.  
  328.   return UpArea
  329.  
  330.